package com.wn.controller;

import com.wn.annotation.RequireRoles;
import com.wn.entity.Routes;
import com.wn.service.RoutesService;
import com.wn.utils.PageParam;
import com.wn.utils.Rsp;
import com.wn.utils.SystemControllerLog;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (Routes)表控制层
 *
 * @author makejava
 * @since 2020-10-26 09:40:41
 */
@RestController
@RequestMapping("routes")
public class RoutesController {
    /**
     * 服务对象
     */
    @Resource
    private RoutesService routesService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Map<String,Object> selectOne(String id) {
        return this.routesService.queryById(id);
    }


    /**
     * 动态查询
     * @param routesPageParam
     * @return
     */
    @SystemControllerLog(description = "分页查询路线信息")
    @PostMapping("/searchSomeRoutesByPage")
    @RequireRoles(roles = {"admin","super_admin","reception","guide","tourist"},index = 1)
    @ApiOperation("查询所有 支持 多条件 分页 排序 查询")
    public Rsp searchSomeByPage(@RequestBody PageParam<Routes> routesPageParam,
                                @RequestHeader("token") String token){

        return Rsp.success(routesService.searchSomeByPage(routesPageParam));
    }

}
